//
//  AboutUSViewController.m
//  ZiJinLian
//
//  Created by 🐛 on 2017/11/30.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "AboutUSViewController.h"
#import "WelcomViewController.h"
#import <SDImageCache.h>
@interface AboutUSViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *version;
@property (strong, nonatomic) UITableView *tableView;

@end

@implementation AboutUSViewController
- (IBAction)goWebClick:(id)sender {
    WelcomViewController*vc=[[WelcomViewController alloc]init];
    vc.reLastURL=@"http://www.zjlwh.net";
    vc.title=MyString(@"紫金莲");
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    ViewRadius(self.imageView, 5);
    [self.view addSubview:self.tableView];
    self.title=MyString(@"关于紫金莲");
	NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
	self.version.text = [NSString stringWithFormat:@"v%@",[infoDictionary objectForKey:@"CFBundleShortVersionString"]];

}
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 125, MainW, 176) style:UITableViewStylePlain];
        _tableView.separatorInset=UIEdgeInsetsZero;
        _tableView.delegate=self;
        _tableView.dataSource=self;
		_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
		_tableView.scrollEnabled = NO;
    }
    return _tableView;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return  1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString * hjID = [NSString stringWithFormat:@"%ldcell%ld",(long)indexPath.section,indexPath.row];
    UITableViewCell * hjcell = [tableView dequeueReusableCellWithIdentifier:hjID];
    if (!hjcell) {
        hjcell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:hjID];
    }
    hjcell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    hjcell.selectionStyle=0;
    hjcell.textLabel.text=@"尼玛";
    hjcell.textLabel.textColor=TextColor3;
    hjcell.textLabel.font=FontAndStyle14;
    //hjcell.detailTextLabel.text=@"尼玛";
    hjcell.detailTextLabel.textColor=TextColor6;
    hjcell.detailTextLabel.font=FontAndStyle14;
    if (indexPath.row==0) {
       hjcell.textLabel.text=MyString(@"关于我们");
    }else if (indexPath.row==1){
        hjcell.textLabel.text=MyString(@"教学");
    }else if (indexPath.row==2){
        hjcell.textLabel.text=MyString(@"法律声明");
    }else if (indexPath.row==3){
        hjcell.textLabel.text=MyString(@"清除缓存");
    }
    return hjcell;
}
#pragma mark ---------- 点击cell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    WelcomViewController*vc=[[WelcomViewController alloc]init];
    
    if (indexPath.row==0) {
        NSLog(@"关于我们");
        vc.reLastURL=[NSString stringWithFormat:@"%@/aboutus.html",baseURL];
        vc.title=MyString(@"关于我们");
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row==1){
//        vc.reLastURL=[NSString stringWithFormat:@"%@",baseURL];
//        vc.title=MyString(@"教学");
//        [self.navigationController pushViewController:vc animated:YES];
      // NSLog(@"教学");
    }else if (indexPath.row==2){
        vc.reLastURL=[NSString stringWithFormat:@"%@/LegalStatement.html",baseURL];
        vc.title=MyString(@"法律声明");
        [self.navigationController pushViewController:vc animated:YES];
        //NSLog(@"法律声明");
    }else if (indexPath.row==3){
        NSLog(@"清除缓存");
        [[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
            [MBProgressHUD showMessage:@"清理中..." toView:self.view];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [self showToast:@"清除成功！"];
            });
            
        }];
    }
    
    
}
@end
